package com.crazyhat.crazyhat.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.crazyhat.crazyhat.dto.MessageDTO;
import com.crazyhat.crazyhat.entity.Message;
import com.crazyhat.crazyhat.pojo.Result;
import com.crazyhat.crazyhat.service.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 消息 前端控制器
 * </p>
 *
 * @author crazyhat
 * @since 2024-07-05
 */
@RestController
@RequestMapping("/message")
public class MessageController {

    @Autowired
    private IMessageService messageService;
    /**
     * 查看消息
     */
    @GetMapping("/checkMassages")
    public Result<Page<MessageDTO>> checkMassages(@RequestParam int pageNum, @RequestParam int pageSize) {

        Page<MessageDTO> messagePage =messageService.checkMassages(pageNum, pageSize);

        if (messagePage!=null) {
            return Result.success(messagePage);
        } else{
            return Result.error("获取消息列表失败");
        }
    }
}
